<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
  <head>
    <title>KernelFixes</title>
    <meta name="generator" content="Muse">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    
    <link rel="stylesheet" type="text/css"charset="utf-8" media="all" href="../../styles/common.css"  />

    <script src="../../scripts/jsMath/easy/load.js"></script>
  </head>

  <body>

    <h1>KernelFixes
      <!-- menu start here -->
      <div class="menu">
        <div class="menuitem">
          <a href="../../home/index.html">Home</a>
        </div>
        <div class="menuitem">
          <a href="../../courses/index.html">Courses</a>
        </div>
        <div class="menuitem">
          <a href="../../projects/index.html">Projects</a>
        </div>
        <div class="menuitem">
          <a href="../../complang/index.html">CompLang</a>
        </div>
        <div class="menuitem">
          <a href="../../code/index.html">CodeReading</a>
        </div>
        <div class="menuitem">
          <a href="../../software/index.html">Software</a>
        </div>
        <div class="menuitem">
          <a href="../../lectures/index.html">Lectures</a>
        </div>
      </div>
      <!-- menu ends here -->

    </h1>


    <!-- Page published by Emacs Muse begins here -->

<h2><code>Error: suffix or operands invalid for `cmp' </code></h2>

<p><a href="http://dunedin.lug.net.nz/forums/showthread.php?s=cf868fd398bed30744e6b6d93e0d0db4&amp;t=80731">http://dunedin.lug.net.nz/forums/showthread.php?s=cf868fd398bed30744e6b6d93e0d0db4&amp;t=80731</a></p>

<p>The __range_ok macro is:</p>

<pre class="src">
<span style="color: #00ffff; font-style: italic;">#define</span> <span style="color: #00ffff;">__range_ok</span>(<span style="color: #ffff00;">addr</span>,<span style="color: #ffff00;">size</span>) ({ \
    <span style="color: #9290ff;">unsigned</span> <span style="color: #9290ff;">long</span> <span style="color: #ffff00;">flag</span>,<span style="color: #ffff00;">sum</span>; \
    __chk_user_ptr(addr); \
    <span style="color: #00ffff; font-weight: bold;">asm</span>(<span style="color: #00ff00;">"addl %3,%1 ; sbbl %0,%0; cmpl %1,%4; sbbl $0,%0"</span> \
        :<span style="color: #00ff00;">"=&amp;r"</span> (flag), <span style="color: #00ff00;">"=r"</span> (sum) \
        :<span style="color: #00ff00;">"1"</span> (addr),<span style="color: #00ff00;">"g"</span> ((<span style="color: #9290ff;">int</span>)(size)),<span style="color: #00ff00;">"g"</span> (current_thread_info()-&gt;addr_limit.seg)); \
    flag; })
</pre>

<p>But gcc optimize the <code>current_thread_info()-&gt;addr_limit.seg</code> as a
constant, and thus cmpl fails.</p>

<p>Fix:</p>

<pre class="src">
<span style="color: #00ffff; font-style: italic;">#define</span> <span style="color: #00ffff;">__range_ok</span>(<span style="color: #ffff00;">addr</span>,<span style="color: #ffff00;">size</span>) ({ \
    <span style="color: #9290ff;">unsigned</span> <span style="color: #9290ff;">long</span> <span style="color: #ffff00;">flag</span>,<span style="color: #ffff00;">sum</span>; \
    __chk_user_ptr(addr); \
    <span style="color: #00ffff; font-weight: bold;">asm</span>(<span style="color: #00ff00;">"addl %3,%1 ; sbbl %0,%0; cmpl %1,%4; sbbl $0,%0"</span> \
        :<span style="color: #00ff00;">"=&amp;r"</span> (flag), <span style="color: #00ff00;">"=r"</span> (sum) \
        :<span style="color: #00ff00;">"1"</span> (addr),<span style="color: #00ff00;">"g"</span> ((<span style="color: #9290ff;">int</span>)(size)),<span style="color: #00ff00;">"r"</span> (current_thread_info()-&gt;addr_limit.seg)); \
    flag; })
</pre>


<h2>undefined reference to `__stack_chk_fail'</h2>

<p class="first">Add <em>-fno-stack-protector</em> to CFLAGS in Makefile</p>



<!-- Page published by Emacs Muse ends here -->
<hl />
<p />
<!-- <center> -->
<!--   Updated at  -->
<!--   2010-03-03 -->
<!-- </center> -->

<script type="text/javascript">
  var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
  document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
  try {
  var pageTracker = _gat._getTracker("UA-2241833-12");
  pageTracker._trackPageview();
  } catch(err) {}</script>

</body>
</html>

